<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>求阶乘</title>
	</head>
	<body>
		<p>请输入一个数：<input type="text" id="num"><button id="a">计算阶乘</button></p>
 		<p>结果是：<span id="jg"></span></p>
		<script>
		document.getElementById("a").onclick=function(){
   		var num=document.getElementById("num").value;
   		var jg=1;
    	for(var i=1;i<=num;i++){
     	 jg*=i;
    	}
   		 document.getElementById("jg").innerHTML=jg;
 		}
			
		</script>
	</body>
</html>
